//== 我发起的
let allList = function () {
    /**
     * 初始化列表
     */
    let initTable = function () {
        let options = {
            url: basePath + '/auth/activiti/history/task-instance/select/all',
            // 列配置
            columns: [
                {
                    field: 'processInstanceId',
                    title: '流水号',
                    width: 140
                },
                {
                    field: 'businessTitle',
                    title: '工作内容'
                },
                {
                    field: 'processDefinitionName',
                    title: '所属流程',
                    template: function (row, index, datatable) {
                        return row.processDefinitionName + ' <span class="badge badge-brand badge--inline badge--pill">v' + row.processVersion + '</span>'
                    }
                },
                {
                    field: 'name',
                    title: '当前步骤'
                },
                {
                    field: 'deleteReason',
                    title: '任务状态',
                    sortable: false,
                    width: 100,
                    template: function (row, index, datatable) {
                        if (row.deleteReason) {
                            // 管理员或发起人撤销
                            return '<span class="badge badge-warning badge--inline badge--pill badge--rounded">已撤销</span>';
                        } else {
                            if (row.endTime == null) {
                                return '<span class="badge badge-info badge--inline badge--pill badge--rounded">办理中</span>';
                            } else {
                                return '<span class="badge badge-success badge--inline badge--pill badge--rounded">已办结</span>';
                            }
                        }
                    }
                },
                {
                    field: 'processSuspensionState',
                    title: '流程状态',
                    width: 100,
                    dictType: 'suspensionState'
                },
                {
                    field: 'startTime',
                    title: '发起时间',
                    width: 150,
                    sortField: 'start_time_',
                    sortable: 'desc'
                },
                {
                    field: 'applyUser',
                    title: '发起人'
                },
                {
                    field: 'Actions',
                    width: 70,
                    title: '操作',
                    sortable: false,
                    overflow: 'visible',
                    locked: {
                        right: 'md'
                    },
                    template: function (row, index, datatable) {
                        let btn = '\
                            <a href="#" onclick="EWorkFlow.openProcessProgress(\'' + row.executionId + '\',\'' + row.processInstanceId + '\', \'' + (row.endTime ? row.endTime : '') + '\')" class="' + ETool.ACTIONS_INFO + '" title="流程跟踪">\
                                <i class="la la-search"></i>\
                            </a>';
                        if (row.endTime == null) {
                            btn += '<a href="#" onclick="EWorkFlow.revokeWithReason(\'' + row.processInstanceId + '\')" class="' + ETool.ACTIONS_INFO + '" title="撤销申请">\
                                <i class="la la-mail-reply"></i>\
                            </a>';
                        }
                        return btn;
                    }
                }

            ]
        };
        allList.dataTable = ETool.initDataTable(options);
    };

    return {
        //== 初始化页面
        init: function () {
            initTable();
        },
    };
}();
/**
 * 当前tab激活时是否需要重新加载数据
 *
 * @return {boolean} true/false
 */
ETab.needSubmitForm = function () {
    return true;
};
//== 初始化
$(document).ready(function () {
    allList.init();
});